﻿

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" />
    <title>抽奖</title>
    <link rel="stylesheet" href="css/kinerlottery.css">
    <link rel="stylesheet" href="css/xiaoyi.css">
</head>
<body>

    <!--头部-->
    <header class="title-box">
        <img class="enroll-logo" style="padding-top:.15rem;margin-left:.15rem;" src="pic/logo.png" alt="">
        <img class="enroll-title" src="pic/enroll-title.png" alt="">
        <img class="book3-rtop" src="pic/book3-rtop.png" alt="">
        <img class="book4-tmiddle" src="pic/book4-tmiddle.png" alt="">
        <!--title-->
        <div class="success-subtitle">
            <img src="pic/draw-subtitle.png" alt="">
        </div>
    </header>


    <!--转盘-->
    <div class="table-box">
        <div id="box" class="box">
            <div class="outer KinerLottery KinerLotteryContent">
                <img src="pic/draw.png">
            </div>
            <!-- 大专盘分为三种状态：活动未开始（no-start）、活动进行中(start)、活动结束(completed),可通过切换class进行切换状态，js会根据这3个class进行匹配状态 -->
            <a href="javascript:" class="inner KinerLotteryBtn start"></a>
        </div>
    </div>

    <div class="rule-box">
        <img class="rule-title" src="pic/rule-title.png" alt="">
        <ul class="draw-rule-box">
            <li>1、报名成功后将此活动链接分享到朋友圈即可获得一次抽奖机会，转发至微信群可额外获得的1次抽奖机会。（每人每天最多可获得5次抽奖机会，分享朋友圈1次＋转发微信群4次）;</li>
            <li>2、中奖奖品为代金券，可按照以下步骤查看：<span>关注公众号“思考乐文化”</span>-<span>底部导航栏“学员中心”</span>-<span>代金券</span>;</li>
            <li>3、实物奖品请在规定时间内到报名时填写分校前台领取(凭学生姓名+家长电话领取);</li>
            <li>4、实物领取时间：<span>2018年5月1日-2018年5月31日，</span>规定时间内未领取算自愿放弃;</li>
            <li>5、代金券仅限报名常规课程<span>(秋季班或寒春班)</span>时使用，每超过1000元可使用100元代金券;</li>
            <li>6、代金券使用时间：<span>2018年7月1日~2018年12月31日</span>。</li>
            <li>7、思考乐教育有权在法律许可的范围内对本活动进行解释。</li>
        </ul>
    </div>

    <script src="js/jquery-3.1.1.min.js"></script>
    <script src="js/kinerlottery.js"></script>
    <script src="js/layer.js"></script>
    <script src="js/font.js"></script>
    <script src="js/publib.js"></script>
        <script src="js/jweixin-1.2.0.js"></script>
        <script type="text/javascript">
            var shareImg = './images/min.png';
            var shareLink = 'https://sic.skl520.com/hd/SumXc';//分享显示页面New4
            var shareDesc = '现读一、三、六、九年级学生暑假来习，学费全免，敬请关注！';
            var shareTitle = '2018思考乐暑假班学费全免，0元学一夏';
            //------------微信js------------
            wx.config({
                debug: false,
                appId: 'wx12be6cfd7335979f',
                timestamp: '1522240713',
                nonceStr: 'Wm3WZYTPz0wzccnW',
                signature: '3d1406df918f78a5008f229f811268fa40b50328',
                jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage']
            });

            //分享朋友圈
            wx.ready(function () {
                wx.onMenuShareTimeline({
                    title: shareTitle,
                    link: shareLink,
                    imgUrl: shareImg,
                    success: function () {
                        $.post("/hd/New1Share", { gettype: 2 }, function (ajaxobj) {
                            showDialogTwo(ajaxobj.msg);
                            if (ajaxobj.status == 0) {
                                window.location = "https://sic.skl520.com/hd/New1Draw";
                            }
                        }, "json");
                    },
                    cancel: function () {
                    }
                });

                //分享给朋友
                wx.onMenuShareAppMessage({
                    title: shareTitle,
                    desc: shareDesc,
                    link: shareLink,
                    imgUrl: shareImg,
                    type: 'link',
                    dataUrl: '',
                    success: function () {
                        $.post("/hd/New1Share", { gettype: 3 }, function (ajaxobj) {
                            showDialogTwo(ajaxobj.msg);
                            if (ajaxobj.status == 0) {
                                window.location = "https://sic.skl520.com/hd/New1Draw";
                            }
                        }, "json");
                    },
                    cancel: function () {
                    }
                });
            });
        </script>
    <script>
        /*
         * 根据转盘旋转角度判断获得什么奖品
         */
        var whichAward = function (deg) {
            $("#d_zj").show();
            if ((deg > 0 && deg <= 36)) {
                $("#zj_img").attr("src", "./images/shouhuan.png");
                $("#zj_txt").html("小米手环");
                return;
            } else if ((deg > 36 && deg <= 72)) {
                $("#zj_img").attr("src", "./images/quan10.png");
                $("#zj_txt").html("10元代金券");
                return;
            } else if (deg > 72 && deg <= 108) {
                $("#zj_img").attr("src", "./images/ipad.png");
                $("#zj_txt").html("iPad");
                return;
            } else if (deg > 108 && deg <= 144) {
                $("#zj_img").attr("src", "./images/wenju.png");
                $("#zj_txt").html("文具套装");
                return;

            } else if (deg > 144 && deg <= 180) {
                $("#zj_img").attr("src", "./images/quan200.png");
                $("#zj_txt").html("200元代金券");
                return;
            } else if (deg > 180 && deg <= 216) {
                $("#zj_img").attr("src", "pic/jiayou.png");
                $("#zj_txt").html("");
                $("#d_zj").hide();
                return;

            } else if (deg > 216 && deg <= 252) {
                $("#zj_img").attr("src", "./images/kindle.png");
                $("#zj_txt").html("阅读器");
                return;
            } else if (deg > 252 && deg <= 288) {
                $("#zj_img").attr("src", "./images/quan100.png");
                $("#zj_txt").html("100元代金券");
                return;
            } else if (deg > 288 && deg <= 324) {
                $("#zj_img").attr("src", "./images/shubao.png");
                $("#zj_txt").html("定制书包");
                return;
            } else if (deg > 324 && deg < 360) {
                $("#zj_img").attr("src", "./images/lele.png");
                $("#zj_txt").html("小乐乐");
                return;
            } else {
                $("#zj_img").attr("src", "./images/nop.png");
                $("#zj_txt").html("请先转发活动");
                $("#d_zj").hide();
                return;
            }

        };

        var ran = 0;

        //获取第一次抽奖的随机数
        $.post("/hd/New1Draw", { cseed: Math.random() }, function (ajaxobj) {
            //有抽奖机会
            if (ajaxobj.status == 0) {
                ran = parseFloat(ajaxobj.data / 10 + 0.05);//中奖的编号
            } else {
                ran = 0;
            }
        }, "json")

        var KinerLottery = new KinerLottery({
            rotateNum: 8, //转盘转动圈数
            body: "#box", //大转盘整体的选择符或zepto对象
            direction: 0, //0为顺时针转动,1为逆时针转动
            disabledHandler: function (key) {
                switch (key) {
                    case "noStart":
                        alert("活动尚未开始");
                        break;
                    case "completed":
                        alert("活动已结束");
                        break;
                }
            }, //禁止抽奖时回调
            clickCallback: function () {
                //此处访问接口获取奖品
                function random() {
                    return Math.floor(ran * 360);
                }
                this.goKinerLottery(random());
            }, //点击抽奖按钮,再次回调中实现访问后台获取抽奖结果,拿到抽奖结果后显示抽奖画面
            KinerLotteryHandler: function (deg) {

                var click = false;
                if (!click) {
                    $.post("/hd/New1Draw", { cseed: Math.random() }, function (ajaxobj) {
                        //有抽奖机会
                        if (ajaxobj.status == 0) {
                            ran = parseFloat(ajaxobj.data / 10 + 0.05);//中奖的编号
                            click = false;
                        } else {
                            ran = 0;
                        }
                    }, "json")
                }

                whichAward(deg);
                // //捕获页
                layer.open({
                    type: 1,
                    shade: [0.7, 'rgb(0, 0, 0)'],
                    area: ['90%', "70%"],
                    offset: ['12%'],
                    scrollbar: false,
                    shadeClose: true,
                    resize: true,
                    title: false, //不显示标题
                    closeBtn: 0,
                    content: $("#gx-box"),   //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
                    success: function (layero, index) {
                        $(".btn-close").on("click", function () {
                            layer.closeAll();
                        })
                    }
                });

            } //抽奖结束回调
        });
    </script>
</body>
</html>

<div id="gx-box" class="gx-box">
    <img class="img-gift" id="zj_img" src="pic/jiayou.png" alt="">
    <div class="gift-box">
        <div id="d_zj">——恭喜你获得——</div>
        <div class="gift-name" id="zj_txt">呆萌小乐乐公仔</div>
    </div>
    <a href="javascript:" class="btn-close"></a>
</div>

